[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
A_MULTIPLY()
Multiply all elements of an array by a value or an array of values
-------------------------------------------------------------------------------
Syntax
A_MULTIPLY( <aTarget>,
[<nValue> | <aValues>],
[<aSource>] )
Arguments
<aTarget> is the array to be modified. If <aSource> is not
specified then each element of <aTarget> will be multiplied by the
<nValue> or element by element by <aValue>.
<nValue> or <aValue> is either a value or an array of values to be
multiplied.
<aSource> is an optional array of values. If specified, then each
element of <aTarget> will be filled with the corresponding value
in <aSource> multiplied by <aValue> or <nValue>.
Returns
Although there is no return value, the <aTarget> array is modified.
Description
A_MULTIPLY() provides a means to perform a multiplication of every
element in the <aSource> array if specified or the <aTarget> array
if not. Each element of the <aSource> or <aTarget> array will be
multiplied by <nValue> or <aValue>. The result of the
multiplication replaces the value in the <aTarget> array.
A_MULTIPLY() can be performed on any integer or floating point
type array. These include the (T)iny, (I)integer, (L)ong, (F)loat
and (D)ouble (both signed and unsigned integers, of course).
Mixing of these types is allowed, however, if the <aTarget> array
is of integer type, decimals will be truncated.
Notes
If the <aTarget> and the <aSource> arrays are not the same
dimensions, the results will be a multiplication element for
element as the arrays are aligned in memory. See chapter two for
how arrays are aligned in memory.
Examples
// Declare three double type arrays for this function.
LOCAL rows, cols
rows = 10
cols = 20
aSource = A_DECLARE( "D", rows, cols )
aTarget = A_DECLARE( "D", rows, cols )
aMultiplier = A_DECLARE( "D", rows, cols )
// Fill the target array with 10's
A_FILL( aTarget, 10, A_(1, 1), rows * cols )
// Multiply every element in the target array by 2
A_MULTIPLY( aTarget, 2 )
? A_RETRIEVE( aTarget, A_( 4, 5 ) ) // Result: 20.0
// Fill the source array with 10's
A_FILL( aSource, 10, A_(1, 1), rows * cols )
// Multiply every element in the source array by five and
// put the result in the target array.
A_MULTIPLY( aTarget, 5, aSource )
? A_RETRIEVE( aTarget, A_( 4, 5 ) ) // Result: 50.0
// Fill the multiplier array with 4's
// Remember the source array still has all 10's
A_FILL( aMultiplier, 4, A_(1, 1), rows * cols )
// Multiply every element in the source array by every element
// in the multiplier array and put the result in the target
// array.
A_MULTIPLY( aTarget, aMultiplier, aSource )
? A_RETRIEVE( aTarget, A_( 4, 5 ) ) // Result: 40.0
See Also:
A_DIVIDE()
A_PLUS()
A_MINUS()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson